package com.heima.media.controller;

import com.heima.common.dto.ResponseResult;
import com.heima.media.entity.WmUser;
import com.heima.media.service.IWmUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 自媒体用户信息表  前端控制器
 */
@RestController
@RequestMapping("api/v1/user")
@Api(tags = "自媒体用户信息表接口")
@CrossOrigin
public class WmUserController {

    @Autowired
    private IWmUserService wmUserService;

    /**
     * 保存自媒体用户
     * @param wmUser
     * @return
     */
    @PostMapping
    @ApiOperation(value = "saveWmUser",notes = "保存自媒体用户")  // value指名称  notes  备注
    @ApiModelProperty(name = "user",dataType = "WmUser",required = true)
    public ResponseResult<WmUser> saveWmUser(@RequestBody WmUser wmUser){
        return wmUserService.saveWmUser(wmUser);
    }

    /**
     * 更新自媒体用户
     * @param wmUser
     * @return
     */
    @PutMapping
    @ApiOperation(value = "updateWmUser",notes = "更新自媒体用户")  // value指名称  notes  备注
    @ApiModelProperty(name = "wmUser",dataType = "WmUser",required = true)
    public ResponseResult updateWmUser(@RequestBody WmUser wmUser){
        wmUserService.updateById(wmUser);
        return ResponseResult.okResult();
    }
}
